# TK Offers a (lightweight) portable approach to GUI widgets.
# This example provides a fileDialog control.
# To be tested on Win32 (ActiveTk)

require 'tk'

def fileDialog(op,dir,ext,window)

    ftypes = [
         ["Currently", ext],
         ["Text files", '*txt'],
         ["Midi files", '*mid'],
         ["Backup files", '*~'],
         ["All files", '*']
    ]
   if op == 'open'
     fname = Tk.getOpenFile('filetypes'=> ftypes, 'parent'=> window,
                            'initialdir' => dir
                            )
   else
     fname = Tk.getSaveFile('filetypes' => ftypes,'parent'=> window,
                             'initialdir' => dir,
                             'initialfile' => Composer.new.title,
                             'defaultextension' => ext
                            )
   end
   return fname
end

file_box = TkFrame.new
dir = '~/'
ext = '*'

ftmp = fileDialog('open', dir, ext, file_box)

# /Applications/TextMate.app/Contents/SharedSupport/Bundles/Subversion.tmbundle/Support